package day5;

import java.util.Scanner;

/**
 * @author oldliu
 * @since 1.0
 */
public class Array11 {
    public static void main(String[] args) {
        int[] a = {95, 88, 82, 70, 65, 0};//最后一个0，表示没有值
        Scanner in = new Scanner(System.in);
        System.out.println("请输入要新成绩：");
        int k = in.nextInt();
        //找合适位置
        int index = 0;
        while (index < a.length - 1 && a[index] > k) {
            index++;
        }
        //移动，从index 到 a.length-2 位置上的数，往后移动一位
        for (int j = a.length - 2; j >= index; j--) {
            a[j + 1] = a[j];
        }
        a[index] = k;
        for (int i = 0; i < a.length; i++) {
            System.out.print(a[i] + "\t");
        }
        System.out.println();
    }
}
